home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / libs / prooflibrary10.lha / prooflibrary / examples / scan / main.c next >
C/C++ Source or Header  |  1999-01-30  |  2KB  |  90 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include <dos/dos.h>
  5. #include <exec/execbase.h>
  6. #include <exec/memory.h>
  7. #include <exec/types.h>
  8.  
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11.  
  12. #include <pragmas/exec_pragmas.h>
  13. #include <pragmas/dos_pragmas.h>
  14.  
  15. #include <proof/proof.h>
  16. #include <proof/proof_protos.h>
  17. #include <proof/proof_pragmas.h>
  18.  
  19. /* Function prototypes */
  20.  
  21. /* Global variables */
  22. extern struct Library *DOSBase;
  23. struct Library *ProofBase;
  24.  
  25. char *version = "$VER: ProofScan 1.0 (19.9.99)";
  26.  
  27. void main( int argc, char **argv )
  28. {
  29.     BPTR lock;
  30.     char str[150];
  31.  
  32.     ProofBase = OpenLibrary( "proof.library", NULL );
  33.     if ( ProofBase != NULL )
  34.     {
  35.         if ( argc > 1 )
  36.         {
  37.             struct FileInfoBlock *fib;
  38.  
  39.             fib = AllocDosObject( DOS_FIB, TAG_DONE );
  40.             if ( fib != NULL )
  41.             {
  42.                 lock = Lock( argv[1], ACCESS_READ );
  43.                 if ( lock != NULL )
  44.                 {
  45.                     if ( Examine( lock, fib ) )
  46.                     {
  47.                         LONG protbits;
  48.  
  49.                         protbits = (LONG)fib->fib_Protection;
  50.  
  51.                         if ( fib->fib_DirEntryType < 0 )
  52.                         {
  53.                             /* File */
  54.                             if ( IsProof( argv[1], PFN_TestProofByProtection, TRUE, NULL ) )
  55.                             {
  56.                                 printf( "PROOF:%s\n", fib->fib_FileName );
  57.                             }
  58.                         }
  59.                         else
  60.                         {
  61.                             /* Directory */
  62.                             while ( ExNext( lock, fib ) != FALSE )
  63.                             {
  64.                                 if ( fib->fib_DirEntryType < 0 )
  65.                                 {
  66.                                     strcpy( str, argv[1]);
  67.                                     AddPart( str, fib->fib_FileName, 150 );
  68.  
  69.                                     if ( IsProof( str, PFN_TestProofByProtection, TRUE, NULL ) )
  70.                                     {
  71.                                         printf( "PROOF:%s\n", fib->fib_FileName );
  72.                                     }
  73.                                 }
  74.                             }
  75.                         }
  76.                     }
  77.  
  78.                     UnLock( lock );
  79.                 }
  80.                 else printf( "Specified file/directory does not exist\n" );
  81.  
  82.                 FreeDosObject( DOS_FIB, fib );
  83.             }
  84.         }
  85.         else printf( "Usage: proofscan <path><filename>\n" );
  86.     }
  87.  
  88.     if ( ProofBase != NULL ) CloseLibrary( ProofBase );
  89. }
  90.